﻿
//自动义双击方法
function CustomDbClick() {
    var recordID = myDataTable.getSelectedRows()[0];
    var record = myDataTable.getRecord(recordID);
    if (record != null) {
        var CustomerId = record.getData("CusID");
        var pagetitle = "查看客户信息";
        parent.$("#tabs").tabs('close', pagetitle);
        parent.addTabs(pagetitle, '../Crm/Customer/AddCustomer.aspx?entity=CrmCustomer&title=' + encodeURI(pagetitle) + '&id=' + CustomerId);
    }  
}
//自定义新增方法
var fnCustomAdd = function () {
}
//自定义修改方法
var fnCustomEdit = function () {
}
//自定义删除方法
var fnCustomDeleteData = function () {
    YAHOO.example.container.dialog3.hide();
}
var fnTeaHodometer = function () {
    var teid = "";
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record != null) {
        teid = record.getData("TeachID")
    }
    parent.addTabs('讲师行程管理', '../Crm/Hodometer/Calendar.aspx?functionID=' + const_functionId + '&TEAID=' + teid);
    //parent.NeedRefreshPage = this;
}

var fnTeachSumup = function () {
    var teid = "";
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record != null) {
        teid = record.getData("TeachID")
    }
    parent.addTabs('讲师演讲总结', '../Crm/Sale/AddTeachSumup.aspx?TEAID=' + teid);
    //parent.NeedRefreshPage = this;
}

if (typeof ($) != "undefined") {
    $(document).ready(function () {
        try {
            var varStr = $("form").attr("action");
            var arr = varStr.split('&');
            var arr2 = new Array();
            for (var i = 1; i < arr.length; i++) {
                arr2.push(arr[i]);
            }
            var varCheck = arr2[0].substring(7, arr2[0].length);
            if (varCheck == "check") {
                $("#fieldForm").wrap("<span id='wrap'></span>");
                var obj = document.getElementById("wrap");
                obj.onmouseover = function () {
                    obj.setCapture();
                }
                obj.onmouseout = function () {
                    obj.releaseCapture();
                }
                obj.onfocus = function () {
                    obj.blur();
                }
                obj.onbeforeactivate = function () {
                    return false;
                }
            }
        } catch (Error) { }
    })
}

var formatText = function (elCell, oRecord, oColumn, sData) {
    sData.replace("[BR]", "");
    if (sData.length > 30) {
        elCell.innerHTML = sData.substring(0, 30) + "..." + "<a href='javascript:CustomDbClick()'>详细</a>";
    }
    else {
        elCell.innerHTML = sData;
    }
};